package cn.jcet.service.impl;

import cn.jcet.domain.User;
import cn.jcet.mapper.UserMapper;
import cn.jcet.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * @author 鲜磊
 */
@Service
public class UserServiceImpl implements UserService {
    /**
     * 注入dao层，查询数据
     */
    @Autowired
    private UserMapper userMapper;

    @Override
    public User queryUserByPhone(String phone) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        // phone常量
        wrapper.eq(User.COL_PHONE,phone);
        // 查询一个
        User user = this.userMapper.selectOne(wrapper);
        return user;
    }

    @Override
    public User getOne(Long userId) {
        // 根据id查询
        User user = this.userMapper.selectById(userId);
        return user;
    }
}
